<?php

namespace App\Trip\Geo\Amap;

use GuzzleHttp\Client;

class Amap
{
    protected string $key;
    protected string $base_url = 'https://restapi.amap.com';
    protected string $output;
    protected Client $client;

    public function __construct()
    {
        $this->key    = config("trip.geo.amap.key");
        $this->output = 'json';
        $this->client = new Client();
    }

    protected function buildQuery(string $url, array $param): string
    {
        $query = $this->base_url."{$url}?key={$this->key}&output={$this->output}";
        foreach ($param as $key => $value) {
            $query .= "&{$key}={$value}";
        }
        return $query;
    }
}